﻿using System.Data.Entity.ModelConfiguration.Conventions;
using Data.Entities;

namespace Data.DbContext
{
    using System;
    using System.Data.Entity;
    using System.Linq;
    /// <summary>
    /// 数据上下文
    /// </summary>
    public class DbEntities : DbContext
    {
        public DbEntities()
            : base("name=WebApp")
        {
        }

        public virtual DbSet<SysConfig> SysConfig { get; set; }
        public virtual DbSet<SysDepartment> SysDepartment { get; set; }
        public virtual DbSet<SysDictionary> SysDictionary { get; set; }
        public virtual DbSet<SysLoginLog> SysLoginLog { get; set; }
        public virtual DbSet<SysModule> SysModule { get; set; }
        public virtual DbSet<SysOperateLog> SysOperateLog { get; set; }
        public virtual DbSet<SysOrganization> SysOrganization { get; set; }
        public virtual DbSet<SysPermission> SysPermission { get; set; }
        public virtual DbSet<SysRole> SysRole { get; set; }
        public virtual DbSet<SysUser> SysUser { get; set; }
        public virtual DbSet<SysUserOrg> SysUserOrg { get; set; }
        public virtual DbSet<SysUserRole> SysUserRole { get; set; }
        public virtual DbSet<SysUserGroup> SysUserGroup { get; set; }
        public virtual DbSet<SysUserGroupMember> SysUserGroupMember { get; set; }
        public virtual DbSet<SysUserGroupRole> SysUserGroupRole { get; set; }
        public virtual DbSet<SysUserLoginInfo> SysUserLoginInfo { get; set; }
        public virtual DbSet<SysUserClaim> SysUserClaim { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }

        /// <summary>
        /// 创建DbEntities
        /// </summary>
        /// <returns></returns>
        public static DbEntities Create()
        {
            return new DbEntities();
        }
    }
}